package com.chezhujie.www.utils;

import sun.misc.BASE64Encoder;

import java.security.MessageDigest;
import java.util.Date;

public class MD5Util {
    public static String md5(String message) {
        try {
            MessageDigest md = MessageDigest.getInstance("md5");
            byte b[] = md.digest(message.getBytes());
            return new BASE64Encoder().encode(b);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public static void main(String[] args) {
        String datestr = LocalDateTime.getDate(new Date(),"yyyy-MM-dd HH")+" tangwj";
        System.out.println(datestr);
        String md5str = MD5Util.md5(datestr);
        System.out.println(md5str);
    }
}
